%% Author: Michael Murphy, mmurphy1@mit.edu
%
%% findHeartRateDiff
%
% Takes in heart rate for both flow and pressure objects and checks to make
% sure they are within 5 bpm of each other
%
%% Syntax
%
% [heartRateDifference] = findHeartRateDiff(flowHeartRate, pressureHeartRate)
%
% [10] = findHeartRateDiff(150, 160)
%
%
%% Description
%
% This function will take in the heart rate for both flow and pressure and
% will check to see if they are within 5 bpm of eachother. If not, this
% function will return a warning message
%
%% Arguments
%
%* flowHeartrate                   - Double: A double precision number of
%                                            the heart rate defined in the 
%                                            flow object
%
%* pressureHeartRate               - Double: A double precision number of 
%                                            the heart rate given by the Pressure 
%                                            object
%
%% Returns
%
%* heartRateDifference             - Double: A double precision number of the 
%                                            difference in heart rates between 
%                                            the flow and pressure objects
%                                     
%
%% Function Side Effects
%
%* Returns a warning message if heartRateDifference is greater than 5
%
%% Exceptions
%
%* An error is thrown if both inputs are not of type double
%
%% See Also
%
%* impedanceOnlyFunc
%
function [heartRateDifference] = findHeartRateDiff(flowHeartRate, pressureHeartRate)

%Checks to make sure that both inputs are of type double
if isa(flowHeartRate, 'double') ~=1
    type = class(flowHeartRate);
    error(sprintf(('Flow heart rate in bpm is of type %s please change to type double'), type))
    
end

if isa(pressureHeartRate, 'double') ~=1
    type = class(pressureHeartRate);
    error(sprintf(('Pressure heart rate in bpm is of type %s please change to type double'), type))
    
end

%Compute the difference in heart rate between the pressure and flow objects
%and throw a warning if this difference is greater than 5
heartRateDifference = abs(flowHeartRate - pressureHeartRate);

if heartRateDifference > 5
    
    warning('Heart rate from pressure and flow are not within 5 bpm of each other')
    
end

return

end

